package com.zghhost.codedemo.ngrok;

import cn.cyejing.ngrok.core.NgrokClient;
import cn.cyejing.ngrok.core.Tunnel;

/**
 * ngrok是一个用开解决内网穿透的优秀开源项目
 * 需要自己搭建服务器（本处借助钉钉的服务）
 * @author guohua.zhang@zhaopin.com.cn
 * @Date 2019/3/28 18:32
 */
public class NgrokTest {
    public static void main(String[] args){
        NgrokProperties ngrokProperties = new NgrokProperties();
        String serverAddress = ngrokProperties.getServerAddress();
        int serverPort = ngrokProperties.getServerPort();
        String subdomain = ngrokProperties.getSubdomain();
        String hostname = ngrokProperties.getHostname();
        String proto = ngrokProperties.getProto();
        int remotePort = ngrokProperties.getRemotePort();
        String httpAuth = ngrokProperties.getHttpAuth();

        Tunnel tunnel = new Tunnel.TunnelBuild()
                .setPort(8080)//指向一个本地端口
                .setProto(proto)
                .setSubDomain(subdomain)
                .setHostname(hostname)
                .setRemotePort(remotePort)
                .setHttpAuth(httpAuth)
                .build();
        new NgrokClient(serverAddress, serverPort)
                .addTunnel(tunnel).start();
    }
}
